package com.learn.collection;


import jxl.Workbook;
import jxl.read.biff.BiffException;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;

import java.io.File;
import java.io.IOException;
import java.util.*;

public class Test {

    public static void main(String[] args) {

        Collection collection = new LinkedList();

        collection.add("hello");
        int i = 6;
        collection.add(i);
        System.out.println(collection.size());
        System.out.println(collection);

        final Date date = new Date();


        System.out.println(((LinkedList) collection).get(0));

        ArrayList collection2 = new
                ArrayList();
        collection2.add("ccc");
        System.out.println(collection2.size());
        System.out.println(collection2);

        System.out.println("--------------");

        List<Integer> integerList = new LinkedList<>();
        List<Integer> integerList2 = null;
//        for(Integer in:integerList2){
//            System.out.println(in);
//        }

        // aa();
        bbbbbbbbbbbbbb();
        List<Integer> arrayList = Arrays.asList(1, 2, 3);

        List arrList = new ArrayList(arrayList);
        arrList.add(4);
        System.out.println(arrList.toString());


    }

    public static void bbbbbbbbbbbbbb() {

        try {

            File file = new File("D:/home/kyapp/uploadfile/20181022/cc.xls");
            //     file.createNewFile();
            Workbook wb = Workbook.getWorkbook(file);
            System.out.println(wb.getSheet(0));
            WritableWorkbook book = Workbook.createWorkbook(file);
            WritableSheet sheet = book.createSheet("sheet11", 0);
//                WritableWorkbook wwb = Workbook.createWorkbook(new FileOutputStream("E:\\b.xls"));
//                //创建第一个工作表对象,名为("Sheet 1)
//                WritableSheet ws = wwb.createSheet("Sheet 1", 0);

        } catch (IOException e) {
            e.printStackTrace();
        } catch (BiffException e) {
            e.printStackTrace();
        }
    }
}

class UserTest{

    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public boolean equals(Object obj) {
        return this.name.equals(((UserTest)obj).name);
    }

    @Override
    public String toString() {
        return this.name;
    }

    public static void main(String[] args) {

        UserTest userTest = new UserTest();
        userTest.setName("666");

        UserTest userTest2 = new UserTest();
        userTest2.setName("77");
        Map map = new HashMap();
        map.put(userTest,888888);
        map.put(userTest,999999);
        map.put(userTest2,88);

        for(Object key : map.keySet()){
            System.out.println(key);
        }

    }


}
